<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>vue</title>
  </head>
  <script src="../vue-2.6.11.js"></script>
  <body>
    <!-- 模板 -->
    <div id="demo">
      <div v-html="html" v-bind:customId="id"></div>

      <div>{{ 1+3 }}</div>

      <div>{{ true ? 'yes': 'no' }}</div>

      <div>{{ message.split('').reverse().join('') }}</div>

      <div>{{ message | capitalize }}</div>

      <blog-post post-title="hello!"></blog-post>
    </div>

    <script>
      //数据
      let data = {
        html: '<div>文本内容</div>',
        id: '_123',
        message: 'abcdef'
      }

      Vue.component('blog-post', {
        // 在 JavaScript 中是 camelCase 的
        props: ['postTitle'],
        template: '<h3>{{ postTitle }}</h3>'
      })

      //vm实例
      let vm = new Vue({
        el: '#demo', //挂载元素
        data: data,
        //过滤器
        filters: {
          capitalize: function(value) {
            if (!value) return ''
            value = value.toString()
            return value.charAt(0).toUpperCase() + value.slice(1)
          }
        }
      })
    </script>
  </body>
</html>
